package hmvc.j2me.controller;

/*
 * Copyright 2008 Jens Meiss
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import hmvc.j2me.IInitializeAble;
import hmvc.j2me.ITerminateAble;
import hmvc.j2me.component.IComponent;
import hmvc.j2me.events.IEvent;
import hmvc.j2me.events.IEventListener;
import hmvc.j2me.model.IModel;
import hmvc.j2me.view.IView;

/**
 * This Interface defines the Controller-Part of this MVC-Implementation
 *
 * @author   jens.meiss
 */
public interface IController extends IInitializeAble, ITerminateAble, IEventListener {

	/**
	 * adds an Controller-Only-Child-Component
	 */
	public IComponent addChildComponent(IController controller);

	/**
	 * adds an Controller-Model-Child-Component
	 * 
	 * @param controller
	 * @param model
	 * @return IComponent
	 */
	public IComponent addChildComponent(IController controller, IModel model);
	
	/**
	 * adds an Controller-Model-View-Child-Component
	 * 
	 * @param controller
	 * @param model
	 * @param view
	 * @return IComponent
	 */
	public IComponent addChildComponent(IController controller,
			IModel model, IView view);
	
	/**
	 * adds an View-Controller-Child-Component
	 * 
	 * @param controller
	 * @param view
	 * @return IComponent
	 */
	public IComponent addChildComponent(IController controller, IView view);
	
	/**
	 * fires the event Down
	 */
	public void fireEventDown(IEvent event);
	
	/**
	 * fires the event to the local listeners
	 */
	public void fireEventLocal(IEvent event);
	
	/**
	 * fires the event Up
	 */
	public void fireEventUp(IEvent event);

	/**
	 * getter of the property component
	 * 
	 * @return IComponent
	 */
	public IComponent getComponent();
	
	/**
	 * registers an EventListener for Events with the given Class
	 * 
	 * @param classOfEvent
	 * @param listener
	 */
	public void register(Class classOfEvent, IEventListener listener);

	/**
	 * setter of the property component
	 * 
	 * @param component
	 */
	public void setComponent(IComponent component);
}
